<?php
    $user_path        = 'public/' . $lastProduct->shop_image_folder .'/';
    $product_img_path = UPLOAD_FOLDER_URL . $user_path . PRODUCT_IMAGE_URL;
    $temp_img_path    = UPLOAD_FOLDER_URL . $user_path . TEMP_FOLDER_URL;
    $aProductImage    = upload_modal_get($product_img_path);
    $aTempImage       = upload_modal_get($temp_img_path);
?>
<div id="modal-change-image" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalChangeImg" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Thay đổi hình đại diện</h4>
            </div>
            <div class="modal-body">
                <div class="image-current">
                    <div class="row">
                        <div class="col-md-12 col-xs-12">
                            <form  role="form" id="frm-upload-img" method="post" action="<?php echo mns_page_url('hinh-anh/tai-len'); ?>" enctype="multipart/form-data">
                                <div class="form-group col-md-6 col-md-offset-2 cpl-xs-6">
                                    <input class="form-control" type="file" name="userfile" />
                                </div>
                                <div class="form-group col-md-1 col-xs-2">
                                    <button id="btn-change-img" class="btn btn-primary">
                                        Tải lên
                                        <span class="percent hidden">0%</span>
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                    <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đang được sử dụng</p>
                    <ul class="image-list clearPad">
                        <?php foreach($aProductImage as $img) { ?>
                        <li>
                            <a href="<?php echo product_upload($img, $lastProduct->shop_image_folder, false); ?>" class="thumbnail img-block-edit product-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='<?php echo PRODUCT_IMAGE_URL; ?>' data-name='<?php echo $img; ?>'>
                                <img class="media-object" src="<?php echo product_upload($img, $lastProduct->shop_image_folder); ?>" />
                            </a>
                        </li>
                        <?php } ?>
                    </ul>
                    <ul class="image-list clearPad">
                        <li class="hidden" id="product-temp-block">
                            <a class="li-temp thumbnail img-block-edit product-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='<?php echo TEMP_FOLDER_URL; ?>' data-name=''>
                                <img class="media-object" />
                            </a>
                        </li>
                    </ul>
                    <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đã tải lên</p>
                    <ul id="image-temp-upload" class="image-list clearPad">
                        <?php foreach($aTempImage as $img) { ?>
                        <li>
                            <a href="<?php echo temp_image($img, $lastProduct->shop_image_folder); ?>" class="li-temp thumbnail img-block-edit product-img-block" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='<?php echo TEMP_FOLDER_URL; ?>' data-name='<?php echo $img; ?>'>
                                <img class="media-object" src="<?php echo temp_image($img, $lastProduct->shop_image_folder, false, true); ?>" />
                            </a>
                        </li>
                        <?php } ?>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="image-resize hidden">
                    <form id="frm-crop" method="POST" action="<?php echo admin_page_url('hinh-anh/crop'); ?>">
                        <div id="img-wrap" data-thumb-width="<?php echo PRODUCT_THUMB_W; ?>" data-screen-width="300">
                            <img src="" id="crop-target" data-ratio="<?php echo PRODUCT_THUMB_RATIO; ?>" />
                        </div>
                        <div class="inline-labels hidden">
                            <label>X1 <input type="hidden" size="4" id="x1" name="crop[x1]" /></label>
                            <label>Y1 <input type="hidden" size="4" id="y1" name="crop[y1]" /></label>
                            <label>X2 <input type="hidden" size="4" id="x2" name="crop[x2]" /></label>
                            <label>Y2 <input type="hidden" size="4" id="y2" name="crop[y2]" /></label>
                            <label>W  <input type="hidden" size="4" id="w"  name="crop[w]" /></label>
                            <label>H  <input type="hidden" size="4" id="h"  name="crop[h]" /></label>
                        </div>
                        <br />
                        <input type="hidden" id="input-crop-path" name="crop[path]" value=""/>
                        <input type="hidden" name="crop[w_case]" value="<?php echo RAOVAT_IMAGE_URL; ?>"/>
                        <button id="btn-crop" type="button" class="btn btn-success" name="submit">Cắt Hình</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>